﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace CodeStatistic
{
    public class CodeFile
    {
        public string file;
        public string fileName;
        public string filePath;
        
        public long fileSize;

        public CodeFile(string file,long fileSize)
        {
            this.file=file;//Example:D:\ab\cd\ef.cs
            int index = file.LastIndexOf("\\");
            filePath=file.Substring(0,index);//Example:D:\ab\cd
            fileName = file.Substring(index+1);//Example:ef.cs
            this.fileSize = fileSize;
        }

        public bool IsExceptionFile()
        {
            foreach(var a in xml_ExceptionFile.Root.Elements())
            {
                if(fileName.Contains(a.Name.ToString())) return true;
            }
            return false;
        }
        public static bool CheckIsExceptionFile(string name)
        {
            foreach (var a in xml_ExceptionFile.Root.Elements())
            {
                if (name.Contains(a.Name.ToString())) return true;
            }
            return false;
        }
        public static XDocument xml_ExceptionFile;

        static CodeFile()
        {
            xml_ExceptionFile = XDocument.Load("ExceptionFile.xml");
        }
    }
    
}
